def get_formatted_name(first_name, last_name, middle_name=''):
    """返回整洁的姓名"""
    if middle_name:
        full_name= first_name + ' ' + middle_name + ' ' + last_name
    else:
        full_name = first_name + ' ' + last_name
    return full_name.title()

musician = get_formatted_name('王', '旭')
print(musician)

musician = get_formatted_name('john', 'hooker', 'lee')
print(musician)

while True:
    print("\nPlease tell me your name:")
    print("(enter 'q' any time to quit!)")

    f_name = input("First name:")
    if f_name == 'q':
        break

    l_name = input("Last name:")
    if l_name == 'q':
        break

    m_name = input("Middle name:")
    if m_name == 'q':
        break

    formatted_name = get_formatted_name(f_name, l_name, m_name)
    print("\nHello, " + formatted_name + "!")
